home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Command processor *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- {$UNDEF debug}
- {$UNDEF DEBUG_REVIEW}
-
- UNIT BBUCMD;
-
- INTERFACE
-
- PROCEDURE user_command(cmd_string : STRING);
-
- IMPLEMENTATION
-
- USES
- CRT,
- bbactcmd,
- bbauth,
- bbconsl,
- bbconv,
- bbdb1,
- bbdummy,
- bbbin,
- bbbug,
- bbfsd,
- bbfsu,
- bbfsw,
- bbfwds,
- bbhelp,
- bbkmc,
- bblmc,
- bbmdata,
- bbmess,
- bbmisc,
- bbmisc2,
- bbmisc4,
- bbocmd,
- bbopro,
- bbopru,
- bbreg,
- bbrmc,
- bbsdata,
- bbsess,
- bbsmc,
- bbstr,
- bbtcmd,
- bbtime;
-
- (*===========================================================================*)
- (* Execute a user command *)
- (*===========================================================================*)
-
- PROCEDURE user_command(cmd_string : STRING);
-
- TYPE p_ptr = PROCEDURE(str_parm : STRING);
-
- VAR
- cmd_word : STRING[20];
- exec_char : CHAR;
- op_command : BOOLEAN;
- rebuild : BOOLEAN;
- uc : user_class_type;
- uf : WORD;
- wd : WORD;
- word_count : BYTE;
-
- {$I BBUCMDMC.PAS} (* Mode change *)
- {$I BBUCMDLT.PAS} (* LTIME command *)
-
- (*=========================================================================*)
- (* Check for restricted command *)
- (*=========================================================================*)
-
- FUNCTION is_restricted : BOOLEAN;
-
- VAR
- i : BYTE;
-
- BEGIN;
-
- is_restricted := TRUE;
-
- i := active_port^.u_restrict;
-
- IF ((i AND restrict_send) <> 0) AND (exec_char = 'S') THEN
- EXIT;
-
- IF ((i AND restrict_upload) <> 0) AND (exec_char = 'U') THEN
- EXIT;
-
- IF ((i AND restrict_download) <> 0) AND (exec_char = 'D') THEN
- EXIT;
-
- IF ((i AND restrict_listread) <> 0) AND (POS(exec_char, 'LRV') <> 0) THEN
- EXIT;
-
- is_restricted := FALSE;
-
- END;
-
- (*=========================================================================*)
- (* Main line *)
- (*=========================================================================*)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Isolate the command string *)
- (*-----------------------------------------------------------------------*)
-
- strip_crlf(cmd_string);
-
- (*-----------------------------------------------------------------------*)
- (* Remove leading LF (if any) *)
- (*-----------------------------------------------------------------------*)
-
- WHILE (LENGTH(cmd_string) > 0) AND (cmd_string[1] = lf) DO
- cmd_string := COPY(cmd_string, 2, 255);
-
- (*-----------------------------------------------------------------------*)
- (* If we didn't get one, ignore this *)
- (*-----------------------------------------------------------------------*)
-
- IF LENGTH(cmd_string) = 0 THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Isolate the command word *)
- (*-----------------------------------------------------------------------*)
-
- word_count := words(cmd_string);
-
- cmd_word := upcase_str(subword(@cmd_string, 1, 1));
-
- (*-----------------------------------------------------------------------*)
- (* Get user info *)
- (*-----------------------------------------------------------------------*)
-
- uc := active_tcb^.uid_data.user_class;
- uf := active_tcb^.uid_data.user_flag;
-
- (*-----------------------------------------------------------------------*)
- (* Check for reverse forward command from a BBS. When it returns *)
- (* force a "B" *)
- (*-----------------------------------------------------------------------*)
-
- IF (cmd_word = 'F>') AND (uc = user_c_bu) THEN
- BEGIN;
- op_command := reverse_forward;
- send_drain;
- IF NOT op_command THEN
- task_wait(2, FALSE);
- end_session(op_command);
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Handle aliases *)
- (*-----------------------------------------------------------------------*)
-
- rebuild := FALSE;
-
- IF cmd_word = 'HELP' THEN
- BEGIN;
- cmd_word := 'H';
- rebuild := TRUE;
- END;
-
- IF cmd_word = 'BYE' THEN
- BEGIN;
- cmd_word := 'B';
- rebuild := TRUE;
- END;
-
- IF cmd_word = 'INFO' THEN
- BEGIN;
- cmd_word := 'I';
- rebuild := TRUE;
- END;
-
- IF cmd_word = 'REGISTER' THEN
- BEGIN;
- cmd_word := 'N';
- rebuild := TRUE;
- END;
-
- IF cmd_word = 'REPLY' THEN
- BEGIN;
- cmd_word := 'SR';
- rebuild := TRUE;
- END;
-
- IF (cmd_word = 'EXPERT') OR
- ((cmd_word = 'X') AND (uc <= user_c_bu)) THEN
- BEGIN;
- cmd_word := 'NE';
- rebuild := TRUE;
- END;
-
- IF (cmd_word = 'SYSOPMSG') AND (word_count = 1) THEN
- BEGIN;
- cmd_word := 'S~';
- cmd_string := 'S~'
- END;
-
- IF rebuild THEN
- BEGIN;
- cmd_string := cmd_word + ' ' + subword(@cmd_string, 2, 0);
- strip_var(cmd_string, 'T');
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Handle special commands *)
- (*-----------------------------------------------------------------------*)
-
- IF cmd_word = 'REVIEW' THEN
- BEGIN;
-
- {$IFDEF DEBUG_REVIEW}
- WRITELN('Review in = ', cmd_string);
- {$ENDIF}
-
- cmd_string := 'V' + subword(@cmd_string, 2, 0);
-
- IF cmd_string = 'V' THEN
- BEGIN;
- IF uc >= user_c_rsu THEN
- cmd_string := 'VV'
- ELSE
- cmd_string := 'VM';
- END;
-
- cmd_word := subword(@cmd_string, 1, 1);
- word_count := words(cmd_string);
-
- {$IFDEF DEBUG_REVIEW}
- WRITELN('Review out = ', cmd_string);
- {$ENDIF}
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* See if sysop wants something *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF debug}
- WRITELN('OC=', ORD(active_tcb^.tcb_type));
- DELAY(2000);
- {$ENDIF}
-
- IF active_tcb^.tcb_sysop_pw_ok AND (uc >= user_c_rsu) THEN
- BEGIN;
-
- op_command := op_cmd(@cmd_string);
-
- IF op_command THEN EXIT;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Long commands *)
- (*-----------------------------------------------------------------------*)
-
- IF (cmd_word = 'CALLBOOK') OR (cmd_word = 'CB') THEN
- BEGIN;
- sam_ulookup_call(cmd_string);
- EXIT;
- END;
-
- IF cmd_word = 'LTIME' THEN
- BEGIN;
- l_time_set;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Command must be 2 characters of less if we get here *)
- (*-----------------------------------------------------------------------*)
-
- IF LENGTH(cmd_word) > 2 THEN
- BEGIN;
- send_message(message_unknown_cmd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* See if this is a mode change. Allowed only if *)
- (* 1. User can be remote sysop and port allows sysop *)
- (* 2. User can be BBS *)
- (* 3. User is local SYSOP *)
- (*-----------------------------------------------------------------------*)
-
- IF (cmd_word[1] = '@') AND
- ((((uf AND user_f_sysop) <> 0) AND active_port^.port_r_sysop)
- OR ((uf AND user_f_bbs) <> 0)
- OR active_tcb^.tcb_console) THEN
- BEGIN;
- user_mode_change;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Now see if this user is restricted *)
- (*-----------------------------------------------------------------------*)
-
- IF (active_port^.u_restrict <> 0)
- AND (((uf AND (user_f_restrict OR user_f_reg_modem)) <> 0)
- OR (uc < active_port^.port_restrict))
- AND is_restricted THEN
- BEGIN;
- send_message(message_cmd_restrict);
- active_tcb^.error_sw := TRUE;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Execute two-letter commands *)
- (*-----------------------------------------------------------------------*)
-
- IF cmd_word = 'DU' THEN
- BEGIN;
- oper_du(cmd_string);
- EXIT;
- END;
-
- IF (cmd_word = 'DB') OR (cmd_word = 'UB') THEN
- BEGIN;
- bin_cmd(cmd_string);
- EXIT;
- END;
-
- IF cmd_word = 'PL' THEN
- BEGIN;
- IF active_port^.port_type = port_modem THEN
- BEGIN;
- active_port^.modem_crlf := NOT active_port^.modem_crlf;
- switch_show(active_port^.modem_crlf);
- END
- ELSE
- switch_show(FALSE);
- EXIT;
- END;
-
- IF (cmd_word[1] = 'V')
- AND ((LENGTH(cmd_word) > 1) OR (word_count > 1)) THEN
- BEGIN;
-
- {$IFDEF DEBUG_REVIEW}
- WRITELN('V command = ', cmd_string);
- DELAY(2000);
- {$ENDIF}
-
- read_msg_cmd(cmd_string);
-
- EXIT;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Execute one letter commands *)
- (*-----------------------------------------------------------------------*)
-
- CASE cmd_word[1] OF
- 'B' : BEGIN;
- IF (LENGTH(cmd_string) <> 1) OR (word_count > 1) THEN
- BEGIN;
- send_message(message_unknown_cmd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF (active_tcb^.tcb_type = th_operator)
- OR (active_tcb^.tcb_type = th_fwd_control) THEN
- BEGIN;
- close_operator_session;
- EXIT;
- END;
-
- send_message(message_goodbye);
- end_session(FALSE);
- END;
-
- 'D' : down_file_cmd(cmd_string);
-
- 'H', '?' : help_cmd(cmd_string);
- 'I' : BEGIN;
- wd := MEMAVAIL div 1024;
- STR(wd, cmd_word);
- set_dollar1_parm (@cmd_word);
- send_message(message_info);
- END;
-
- 'J' : activity_cmd(cmd_string);
-
- 'K' : kill_msg_cmd(cmd_string);
- 'L' : list_msg_cmd(cmd_string);
- 'N' : register_cmd(cmd_string);
-
- 'R' : read_msg_cmd(cmd_string);
-
- 'S' :
- BEGIN;
- send_msg_cmd(cmd_string);
- active_tcb^.tcb_rcv_msg := FALSE;
- END;
-
- 'T' : talk_cmd(cmd_string);
-
- 'U' : upload_file_cmd(cmd_string);
-
- 'V' : send_tnc_data_str(this_bbs_version + cr);
-
- 'W' : list_dir_cmd(cmd_string);
-
- ELSE
- BEGIN;
- send_message(message_unknown_cmd);
- active_tcb^.error_sw := TRUE;
- END;
-
- END;
-
- END;
-
- END.